.class public Lcom/opongo/blogapp/adapter/CommentViewAdapter;
.super Landroid/widget/ArrayAdapter;
.source "CommentViewAdapter.java"


# annotations
.annotation system Ldalvik/annotation/MemberClasses;
    value = {
        Lcom/opongo/blogapp/adapter/CommentViewAdapter$ViewHolder;
    }
.end annotation

.annotation system Ldalvik/annotation/Signature;
    value = {
        "Landroid/widget/ArrayAdapter",
        "<",
        "Lcom/opongo/blogapp/common/Comment;",
        ">;"
    }
.end annotation


# static fields
.field public static final DEBUG:Z

.field private static final TAG:Ljava/lang/String;


# instance fields
.field private activity:Landroid/app/Activity;

.field private comments:Ljava/util/ArrayList;
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "Ljava/util/ArrayList",
            "<",
            "Lcom/opongo/blogapp/common/Comment;",
            ">;"
        }
    .end annotation
.end field

.field private df:Ljava/text/DateFormat;

.field private imageManager:Lcom/opongo/blogapp/manager/ImageManager;

.field private mInflater:Landroid/view/LayoutInflater;

.field private pTime:Lcom/ocpsoft/pretty/time/PrettyTime;


# direct methods
.method static constructor <clinit>()V
    .locals 1

    .prologue
    .line 36
    sget-boolean v0, Lcom/opongo/blogapp/AbaSettings;->DEBUG:Z

    sput-boolean v0, Lcom/opongo/blogapp/adapter/CommentViewAdapter;->DEBUG:Z

    .line 37
    const-class v0, Lcom/opongo/blogapp/adapter/CommentViewAdapter;

    invoke-virtual {v0}, Ljava/lang/Class;->getSimpleName()Ljava/lang/String;

    move-result-object v0

    sput-object v0, Lcom/opongo/blogapp/adapter/CommentViewAdapter;->TAG:Ljava/lang/String;

    .line 33
    return-void
.end method

.method public constructor <init>(Landroid/app/Activity;Landroid/content/Context;ILjava/util/ArrayList;)V
    .locals 3
    .parameter "activity"
    .parameter "context"
    .parameter "textViewResourceId"
    .parameter
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "(",
            "Landroid/app/Activity;",
            "Landroid/content/Context;",
            "I",
            "Ljava/util/ArrayList",
            "<",
            "Lcom/opongo/blogapp/common/Comment;",
            ">;)V"
        }
    .end annotation

    .prologue
    .line 48
    .local p4, comments:Ljava/util/ArrayList;,"Ljava/util/ArrayList<Lcom/opongo/blogapp/common/Comment;>;"
    invoke-direct {p0, p2, p3, p4}, Landroid/widget/ArrayAdapter;-><init>(Landroid/content/Context;ILjava/util/List;)V

    .line 50
    iput-object p4, p0, Lcom/opongo/blogapp/adapter/CommentViewAdapter;->comments:Ljava/util/ArrayList;

    .line 51
    iput-object p1, p0, Lcom/opongo/blogapp/adapter/CommentViewAdapter;->activity:Landroid/app/Activity;

    .line 53
    new-instance v0, Ljava/text/SimpleDateFormat;

    const-string v1, "yyyy-MM-dd HH:mm:ss"

    invoke-direct {v0, v1}, Ljava/text/SimpleDateFormat;-><init>(Ljava/lang/String;)V

    iput-object v0, p0, Lcom/opongo/blogapp/adapter/CommentViewAdapter;->df:Ljava/text/DateFormat;

    .line 54
    new-instance v0, Lcom/ocpsoft/pretty/time/PrettyTime;

    new-instance v1, Ljava/util/Locale;

    const-string v2, "de"

    invoke-direct {v1, v2}, Ljava/util/Locale;-><init>(Ljava/lang/String;)V

    invoke-direct {v0, v1}, Lcom/ocpsoft/pretty/time/PrettyTime;-><init>(Ljava/util/Locale;)V

    iput-object v0, p0, Lcom/opongo/blogapp/adapter/CommentViewAdapter;->pTime:Lcom/ocpsoft/pretty/time/PrettyTime;

    .line 57
    invoke-static {p2}, Landroid/view/LayoutInflater;->from(Landroid/content/Context;)Landroid/view/LayoutInflater;

    move-result-object v0

    iput-object v0, p0, Lcom/opongo/blogapp/adapter/CommentViewAdapter;->mInflater:Landroid/view/LayoutInflater;

    .line 59
    new-instance v0, Lcom/opongo/blogapp/manager/ImageManager;

    invoke-direct {v0, p2}, Lcom/opongo/blogapp/manager/ImageManager;-><init>(Landroid/content/Context;)V

    iput-object v0, p0, Lcom/opongo/blogapp/adapter/CommentViewAdapter;->imageManager:Lcom/opongo/blogapp/manager/ImageManager;

    .line 60
    return-void
.end method

.method static synthetic access$0()Ljava/lang/String;
    .locals 1

    .prologue
    .line 37
    sget-object v0, Lcom/opongo/blogapp/adapter/CommentViewAdapter;->TAG:Ljava/lang/String;

    return-object v0
.end method

.method static synthetic access$1(Lcom/opongo/blogapp/adapter/CommentViewAdapter;)Landroid/app/Activity;
    .locals 1
    .parameter

    .prologue
    .line 44
    iget-object v0, p0, Lcom/opongo/blogapp/adapter/CommentViewAdapter;->activity:Landroid/app/Activity;

    return-object v0
.end method

.method private getRang(II)I
    .locals 3
    .parameter "parent_id"
    .parameter "rang"

    .prologue
    .line 75
    iget-object v1, p0, Lcom/opongo/blogapp/adapter/CommentViewAdapter;->comments:Ljava/util/ArrayList;

    invoke-virtual {v1}, Ljava/util/ArrayList;->iterator()Ljava/util/Iterator;

    move-result-object v1

    :cond_0
    :goto_0
    invoke-interface {v1}, Ljava/util/Iterator;->hasNext()Z

    move-result v2

    if-nez v2, :cond_1

    .line 80
    return p2

    .line 75
    :cond_1
    invoke-interface {v1}, Ljava/util/Iterator;->next()Ljava/lang/Object;

    move-result-object v0

    check-cast v0, Lcom/opongo/blogapp/common/Comment;

    .line 76
    .local v0, comment:Lcom/opongo/blogapp/common/Comment;
    iget v2, v0, Lcom/opongo/blogapp/common/Comment;->id:I

    if-ne v2, p1, :cond_0

    .line 77
    iget v2, v0, Lcom/opongo/blogapp/common/Comment;->parent:I

    add-int/lit8 p2, p2, 0x1

    invoke-direct {p0, v2, p2}, Lcom/opongo/blogapp/adapter/CommentViewAdapter;->getRang(II)I

    move-result p2

    goto :goto_0
.end method


# virtual methods
.method public getView(ILandroid/view/View;Landroid/view/ViewGroup;)Landroid/view/View;
    .locals 12
    .parameter "position"
    .parameter "convertView"
    .parameter "parent"

    .prologue
    .line 90
    move-object v6, p2

    .line 92
    .local v6, view:Landroid/view/View;
    if-nez v6, :cond_0

    .line 95
    iget-object v8, p0, Lcom/opongo/blogapp/adapter/CommentViewAdapter;->mInflater:Landroid/view/LayoutInflater;

    const v9, 0x7f030006

    .line 96
    const/4 v10, 0x0

    .line 95
    invoke-virtual {v8, v9, p3, v10}, Landroid/view/LayoutInflater;->inflate(ILandroid/view/ViewGroup;Z)Landroid/view/View;

    move-result-object v6

    .line 99
    new-instance v7, Lcom/opongo/blogapp/adapter/CommentViewAdapter$ViewHolder;

    invoke-direct {v7}, Lcom/opongo/blogapp/adapter/CommentViewAdapter$ViewHolder;-><init>()V

    .line 104
    .local v7, viewHolder:Lcom/opongo/blogapp/adapter/CommentViewAdapter$ViewHolder;
    const v8, 0x7f08001b

    invoke-virtual {v6, v8}, Landroid/view/View;->findViewById(I)Landroid/view/View;

    move-result-object v8

    check-cast v8, Landroid/widget/ImageView;

    #setter for: Lcom/opongo/blogapp/adapter/CommentViewAdapter$ViewHolder;->mGravatarImg:Landroid/widget/ImageView;
    invoke-static {v7, v8}, Lcom/opongo/blogapp/adapter/CommentViewAdapter$ViewHolder;->access$0(Lcom/opongo/blogapp/adapter/CommentViewAdapter$ViewHolder;Landroid/widget/ImageView;)V

    .line 105
    const v8, 0x7f08001d

    invoke-virtual {v6, v8}, Landroid/view/View;->findViewById(I)Landroid/view/View;

    move-result-object v8

    check-cast v8, Landroid/widget/TextView;

    #setter for: Lcom/opongo/blogapp/adapter/CommentViewAdapter$ViewHolder;->mAuthorText:Landroid/widget/TextView;
    invoke-static {v7, v8}, Lcom/opongo/blogapp/adapter/CommentViewAdapter$ViewHolder;->access$1(Lcom/opongo/blogapp/adapter/CommentViewAdapter$ViewHolder;Landroid/widget/TextView;)V

    .line 106
    const v8, 0x7f08001e

    invoke-virtual {v6, v8}, Landroid/view/View;->findViewById(I)Landroid/view/View;

    move-result-object v8

    check-cast v8, Landroid/widget/TextView;

    #setter for: Lcom/opongo/blogapp/adapter/CommentViewAdapter$ViewHolder;->mDateText:Landroid/widget/TextView;
    invoke-static {v7, v8}, Lcom/opongo/blogapp/adapter/CommentViewAdapter$ViewHolder;->access$2(Lcom/opongo/blogapp/adapter/CommentViewAdapter$ViewHolder;Landroid/widget/TextView;)V

    .line 107
    const v8, 0x7f08001f

    invoke-virtual {v6, v8}, Landroid/view/View;->findViewById(I)Landroid/view/View;

    move-result-object v8

    check-cast v8, Landroid/widget/TextView;

    #setter for: Lcom/opongo/blogapp/adapter/CommentViewAdapter$ViewHolder;->mContentText:Landroid/widget/TextView;
    invoke-static {v7, v8}, Lcom/opongo/blogapp/adapter/CommentViewAdapter$ViewHolder;->access$3(Lcom/opongo/blogapp/adapter/CommentViewAdapter$ViewHolder;Landroid/widget/TextView;)V

    .line 108
    const v8, 0x7f080020

    invoke-virtual {v6, v8}, Landroid/view/View;->findViewById(I)Landroid/view/View;

    move-result-object v8

    check-cast v8, Landroid/widget/TextView;

    #setter for: Lcom/opongo/blogapp/adapter/CommentViewAdapter$ViewHolder;->mAddComment:Landroid/widget/TextView;
    invoke-static {v7, v8}, Lcom/opongo/blogapp/adapter/CommentViewAdapter$ViewHolder;->access$4(Lcom/opongo/blogapp/adapter/CommentViewAdapter$ViewHolder;Landroid/widget/TextView;)V

    .line 110
    invoke-virtual {v6, v7}, Landroid/view/View;->setTag(Ljava/lang/Object;)V

    .line 113
    .end local v7           #viewHolder:Lcom/opongo/blogapp/adapter/CommentViewAdapter$ViewHolder;
    :cond_0
    iget-object v8, p0, Lcom/opongo/blogapp/adapter/CommentViewAdapter;->comments:Ljava/util/ArrayList;

    invoke-virtual {v8, p1}, Ljava/util/ArrayList;->get(I)Ljava/lang/Object;

    move-result-object v0

    check-cast v0, Lcom/opongo/blogapp/common/Comment;

    .line 115
    .local v0, c:Lcom/opongo/blogapp/common/Comment;
    if-eqz v0, :cond_2

    .line 118
    const/4 v1, 0x0

    .line 120
    .local v1, date:Ljava/util/Date;
    :try_start_0
    iget-object v8, p0, Lcom/opongo/blogapp/adapter/CommentViewAdapter;->df:Ljava/text/DateFormat;

    iget-object v9, v0, Lcom/opongo/blogapp/common/Comment;->date:Ljava/lang/String;

    invoke-virtual {v8, v9}, Ljava/text/DateFormat;->parse(Ljava/lang/String;)Ljava/util/Date;
    :try_end_0
    .catch Ljava/text/ParseException; {:try_start_0 .. :try_end_0} :catch_0

    move-result-object v1

    .line 125
    :goto_0
    invoke-virtual {v6}, Landroid/view/View;->getTag()Ljava/lang/Object;

    move-result-object v7

    check-cast v7, Lcom/opongo/blogapp/adapter/CommentViewAdapter$ViewHolder;

    .line 128
    .restart local v7       #viewHolder:Lcom/opongo/blogapp/adapter/CommentViewAdapter$ViewHolder;
    #getter for: Lcom/opongo/blogapp/adapter/CommentViewAdapter$ViewHolder;->mAuthorText:Landroid/widget/TextView;
    invoke-static {v7}, Lcom/opongo/blogapp/adapter/CommentViewAdapter$ViewHolder;->access$5(Lcom/opongo/blogapp/adapter/CommentViewAdapter$ViewHolder;)Landroid/widget/TextView;

    move-result-object v9

    iget-object v8, v0, Lcom/opongo/blogapp/common/Comment;->author:Ljava/lang/String;

    const-string v10, ""

    invoke-virtual {v8, v10}, Ljava/lang/String;->equals(Ljava/lang/Object;)Z

    move-result v8

    if-eqz v8, :cond_3

    const-string v8, "Gast"

    :goto_1
    invoke-virtual {v9, v8}, Landroid/widget/TextView;->setText(Ljava/lang/CharSequence;)V

    .line 131
    #getter for: Lcom/opongo/blogapp/adapter/CommentViewAdapter$ViewHolder;->mDateText:Landroid/widget/TextView;
    invoke-static {v7}, Lcom/opongo/blogapp/adapter/CommentViewAdapter$ViewHolder;->access$6(Lcom/opongo/blogapp/adapter/CommentViewAdapter$ViewHolder;)Landroid/widget/TextView;

    move-result-object v8

    iget-object v9, p0, Lcom/opongo/blogapp/adapter/CommentViewAdapter;->pTime:Lcom/ocpsoft/pretty/time/PrettyTime;

    invoke-virtual {v9, v1}, Lcom/ocpsoft/pretty/time/PrettyTime;->format(Ljava/util/Date;)Ljava/lang/String;

    move-result-object v9

    invoke-virtual {v8, v9}, Landroid/widget/TextView;->setText(Ljava/lang/CharSequence;)V

    .line 134
    #getter for: Lcom/opongo/blogapp/adapter/CommentViewAdapter$ViewHolder;->mContentText:Landroid/widget/TextView;
    invoke-static {v7}, Lcom/opongo/blogapp/adapter/CommentViewAdapter$ViewHolder;->access$7(Lcom/opongo/blogapp/adapter/CommentViewAdapter$ViewHolder;)Landroid/widget/TextView;

    move-result-object v8

    iget-object v9, v0, Lcom/opongo/blogapp/common/Comment;->content:Ljava/lang/String;

    invoke-virtual {v8, v9}, Landroid/widget/TextView;->setText(Ljava/lang/CharSequence;)V

    .line 136
    const/4 v5, 0x0

    .line 138
    .local v5, rang:I
    iget v8, v0, Lcom/opongo/blogapp/common/Comment;->parent:I

    if-eqz v8, :cond_1

    .line 139
    iget v8, v0, Lcom/opongo/blogapp/common/Comment;->parent:I

    invoke-direct {p0, v8, v5}, Lcom/opongo/blogapp/adapter/CommentViewAdapter;->getRang(II)I

    move-result v5

    .line 142
    :cond_1
    mul-int/lit8 v8, v5, 0x1e

    add-int/lit8 v8, v8, 0xf

    const/16 v9, 0xf

    const/16 v10, 0xf

    const/16 v11, 0xa

    invoke-virtual {v6, v8, v9, v10, v11}, Landroid/view/View;->setPadding(IIII)V

    .line 145
    #getter for: Lcom/opongo/blogapp/adapter/CommentViewAdapter$ViewHolder;->mAddComment:Landroid/widget/TextView;
    invoke-static {v7}, Lcom/opongo/blogapp/adapter/CommentViewAdapter$ViewHolder;->access$8(Lcom/opongo/blogapp/adapter/CommentViewAdapter$ViewHolder;)Landroid/widget/TextView;

    move-result-object v8

    iget v9, v0, Lcom/opongo/blogapp/common/Comment;->id:I

    invoke-static {v9}, Ljava/lang/String;->valueOf(I)Ljava/lang/String;

    move-result-object v9

    invoke-virtual {v8, v9}, Landroid/widget/TextView;->setTag(Ljava/lang/Object;)V

    .line 146
    iget v4, v0, Lcom/opongo/blogapp/common/Comment;->postId:I

    .line 148
    .local v4, post_id:I
    #getter for: Lcom/opongo/blogapp/adapter/CommentViewAdapter$ViewHolder;->mAddComment:Landroid/widget/TextView;
    invoke-static {v7}, Lcom/opongo/blogapp/adapter/CommentViewAdapter$ViewHolder;->access$8(Lcom/opongo/blogapp/adapter/CommentViewAdapter$ViewHolder;)Landroid/widget/TextView;

    move-result-object v8

    new-instance v9, Lcom/opongo/blogapp/adapter/CommentViewAdapter$1;

    invoke-direct {v9, p0, v4}, Lcom/opongo/blogapp/adapter/CommentViewAdapter$1;-><init>(Lcom/opongo/blogapp/adapter/CommentViewAdapter;I)V

    invoke-virtual {v8, v9}, Landroid/widget/TextView;->setOnClickListener(Landroid/view/View$OnClickListener;)V

    .line 162
    iget-object v3, v0, Lcom/opongo/blogapp/common/Comment;->gravatarUrl:Ljava/lang/String;

    .line 163
    .local v3, imgUrl:Ljava/lang/String;
    #getter for: Lcom/opongo/blogapp/adapter/CommentViewAdapter$ViewHolder;->mGravatarImg:Landroid/widget/ImageView;
    invoke-static {v7}, Lcom/opongo/blogapp/adapter/CommentViewAdapter$ViewHolder;->access$9(Lcom/opongo/blogapp/adapter/CommentViewAdapter$ViewHolder;)Landroid/widget/ImageView;

    move-result-object v8

    if-eqz v8, :cond_6

    if-eqz v3, :cond_6

    .line 164
    invoke-virtual {v3}, Ljava/lang/String;->length()I

    move-result v8

    const/16 v9, 0xa

    if-le v8, v9, :cond_4

    .line 165
    iget-object v8, p0, Lcom/opongo/blogapp/adapter/CommentViewAdapter;->imageManager:Lcom/opongo/blogapp/manager/ImageManager;

    iget-object v9, p0, Lcom/opongo/blogapp/adapter/CommentViewAdapter;->activity:Landroid/app/Activity;

    #getter for: Lcom/opongo/blogapp/adapter/CommentViewAdapter$ViewHolder;->mGravatarImg:Landroid/widget/ImageView;
    invoke-static {v7}, Lcom/opongo/blogapp/adapter/CommentViewAdapter$ViewHolder;->access$9(Lcom/opongo/blogapp/adapter/CommentViewAdapter$ViewHolder;)Landroid/widget/ImageView;

    move-result-object v10

    invoke-virtual {v8, v3, v9, v10}, Lcom/opongo/blogapp/manager/ImageManager;->displayImage(Ljava/lang/String;Landroid/app/Activity;Landroid/widget/ImageView;)V

    .line 176
    .end local v1           #date:Ljava/util/Date;
    .end local v3           #imgUrl:Ljava/lang/String;
    .end local v4           #post_id:I
    .end local v5           #rang:I
    .end local v7           #viewHolder:Lcom/opongo/blogapp/adapter/CommentViewAdapter$ViewHolder;
    :cond_2
    :goto_2
    return-object v6

    .line 121
    .restart local v1       #date:Ljava/util/Date;
    :catch_0
    move-exception v2

    .line 122
    .local v2, e:Ljava/text/ParseException;
    invoke-virtual {v2}, Ljava/text/ParseException;->printStackTrace()V

    goto/16 :goto_0

    .line 128
    .end local v2           #e:Ljava/text/ParseException;
    .restart local v7       #viewHolder:Lcom/opongo/blogapp/adapter/CommentViewAdapter$ViewHolder;
    :cond_3
    iget-object v8, v0, Lcom/opongo/blogapp/common/Comment;->author:Ljava/lang/String;

    goto :goto_1

    .line 167
    .restart local v3       #imgUrl:Ljava/lang/String;
    .restart local v4       #post_id:I
    .restart local v5       #rang:I
    :cond_4
    sget-boolean v8, Lcom/opongo/blogapp/adapter/CommentViewAdapter;->DEBUG:Z

    if-eqz v8, :cond_5

    sget-object v8, Lcom/opongo/blogapp/adapter/CommentViewAdapter;->TAG:Ljava/lang/String;

    new-instance v9, Ljava/lang/StringBuilder;

    const-string v10, "Image url to short to be valid: "

    invoke-direct {v9, v10}, Ljava/lang/StringBuilder;-><init>(Ljava/lang/String;)V

    invoke-virtual {v9, v3}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v9

    invoke-virtual {v9}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v9

    invoke-static {v8, v9}, Landroid/util/Log;->d(Ljava/lang/String;Ljava/lang/String;)I

    .line 168
    :cond_5
    #getter for: Lcom/opongo/blogapp/adapter/CommentViewAdapter$ViewHolder;->mGravatarImg:Landroid/widget/ImageView;
    invoke-static {v7}, Lcom/opongo/blogapp/adapter/CommentViewAdapter$ViewHolder;->access$9(Lcom/opongo/blogapp/adapter/CommentViewAdapter$ViewHolder;)Landroid/widget/ImageView;

    move-result-object v8

    const v9, 0x7f020008

    invoke-virtual {v8, v9}, Landroid/widget/ImageView;->setImageResource(I)V

    goto :goto_2

    .line 171
    :cond_6
    #getter for: Lcom/opongo/blogapp/adapter/CommentViewAdapter$ViewHolder;->mGravatarImg:Landroid/widget/ImageView;
    invoke-static {v7}, Lcom/opongo/blogapp/adapter/CommentViewAdapter$ViewHolder;->access$9(Lcom/opongo/blogapp/adapter/CommentViewAdapter$ViewHolder;)Landroid/widget/ImageView;

    move-result-object v8

    const v9, 0x7f020008

    invoke-virtual {v8, v9}, Landroid/widget/ImageView;->setImageResource(I)V

    .line 172
    sget-boolean v8, Lcom/opongo/blogapp/adapter/CommentViewAdapter;->DEBUG:Z

    if-eqz v8, :cond_2

    sget-object v8, Lcom/opongo/blogapp/adapter/CommentViewAdapter;->TAG:Ljava/lang/String;

    const-string v9, "Thumbnail holder is null!"

    invoke-static {v8, v9}, Landroid/util/Log;->d(Ljava/lang/String;Ljava/lang/String;)I

    goto :goto_2
.end method

.method public stopImgLoaderThread()V
    .locals 1

    .prologue
    .line 180
    iget-object v0, p0, Lcom/opongo/blogapp/adapter/CommentViewAdapter;->imageManager:Lcom/opongo/blogapp/manager/ImageManager;

    invoke-virtual {v0}, Lcom/opongo/blogapp/manager/ImageManager;->stopThread()V

    .line 181
    return-void
.end method
